package com.wisdom.admin.bo;

import com.wisdom.admin.mbg.model.UmsAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @author ming
 * @ClassName AdminUserDetails.java
 * @Description SpringSecurity需要的用户详情
 * @createTime 2021年03月16日 22:26:00
 */
public class AdminUserDetails implements UserDetails {

    @Autowired
    private UmsAdmin umsAdmin;

    public AdminUserDetails(UmsAdmin umsAdmin)
    {
        this.umsAdmin = umsAdmin;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return umsAdmin.getPassword();
    }

    @Override
    public String getUsername() {
        return umsAdmin.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return umsAdmin.getStatus().equals(1);
    }
}
